package com.fowo.api.sys.controller;

import com.fowo.api.common.model.R;
import com.fowo.api.sys.service.SysRandomImageService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

/**
 * 提供随机验证码生成
 */
@RestController
@RequestMapping("/api/sys/randomImage")
@Tag(name = "随机验证码生成")
public class SysRandomImageController {

    @Resource
    private SysRandomImageService sysRandomImageService;

    @GetMapping("{key}")
    @Operation(summary = "获取新的随机验证码，图片的 Base64 字符串")
    public R<String> getNewRandomImageBase64(@PathVariable("key") String key) {
        return R.data(sysRandomImageService.getNewRandomImageBase64(key));
    }
}
